import { Injectable } from '@angular/core';

@Injectable({ providedIn: 'root' })
export class MessageContainerService {
  public messages = {
    topLeft: [],
    topCenter: [],
    topRight: [],
  };

  remove(cdr, tag, id): void {
    const messages = this.messages[tag];
    messages.some((item, index): boolean => {
      if (item.id === id) {
        messages.splice(index, 1);
        cdr.detectChanges();
        return true;
      }
      return false;
    });
  }
}
